package com.lwf.component.spider.article;

import com.lwf.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

@Component
public class ArticlePipelineline implements Pipeline {
    @Autowired
    private ArticleService articleService;

    @Override
    public void process(ResultItems resultItems, Task task) {
        String title = resultItems.get("title");
        String htmlStr = resultItems.get("htmlStr");
        String url = resultItems.get("url");
        articleService.insertArticle(title, htmlStr, url);
    }
}
